<!DOCTYPE html>
<html>
  <head>
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title><%= title %></title>
    <link rel="stylesheet" href="/stylesheets/style.css" />
    <link
      rel="stylesheet"
      href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css"
      integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu"
      crossorigin="anonymous"
    />
  </head>
  <body>
    <nav class="navbar navbar-default">
      <div class="row flex-center">
        <div class="col-xs-12 col-md-8">
          <p class="navbar-brand"><%= title %></p>
        </div>
        <div class="col-xs-6 col-md-4 text-right">
          <a href="/users/order" class="navbar-link">
            <button type="button" class="btn btn-primary">回到列表</button>
          </a>
        </div>
      </div>
    </nav>

    <% if(data._id) { %>
      <form method="post" action="/users/order/update/<%= data._id %>">
    <% } else { %>
      <form method="post" action="/users/order/create">
    <% } %>
      <div class="form-group margin-botton-50">
        <label for="orderText">事项</label>
        <input
          type="text"
          class="form-control"
          placeholder="请输入此条记录的详细原由"
          name="orderText"
          id="basic-addon1"
          required
          value="<% if(data._id) { %><%= data.text %><% } %>"
        />
      </div>
      <div class="form-group">
        <label for="orderDate">日期</label>
        <input
          type="text"
          class="form-control"
          placeholder="请输入此条记录发生的时间"
          name="orderDate"
          id="basic-addon2"
          required
          value="<% if(data._id) { %><%= data.createTime %><% } %>"
        />
      </div>
      <div class="form-group">
        <label id="basic-addon3">类型</label>
        <label class="radio-inline"  for="inlineRadio1">
          <input type="radio" name="orderType" id="inlineRadio1" 
          value="1" required /> 收入
        </label>
        <label class="radio-inline" for="inlineRadio2">
          <input type="radio" name="orderType" id="inlineRadio2" 
          value="-1" required /> 支出
        </label>
      </div>
      <div class="form-group">
        <label for="orderValue">金额</label>
        <input
          type="text"
          class="form-control"
          placeholder="请输入此条记录的金额数值"
          name="orderValue"
          id="basic-addon4"
          required
          value="<% if(data._id) { %><%= data.moneyValue %><% } %>"
        />
      </div>
      <div class="form-group">
        <label for="orderDescription">备注</label>
        <input
          type="text"
          class="form-control"
          placeholder="请输入备注信息（可选）"
          name="orderDescription"
          id="basic-addon5"
          required
          value="<% if(data._id) { %><%= data.description %><% } %>"
        />
      </div>

      <button type="submit" class="btn btn-primary btn-block">
        <% if(data._id) { %>
          更新
        <% } else { %>
          创建
        <% } %>
      </button>
    </form>
  </body>
</html>
